export const storage = {
    get: (key) => {
        return new Promise((resolve, reject) => {
            try {
                chrome.storage.local.get(key).then(lay => {
                    resolve(lay[key]);
                })
            } catch (e) {
                resolve(window.localStorage.getItem(key));
            }
        });
    },
    set: (key, value) => {
        return new Promise((resolve, reject) => {
            try {
                const obj = {};
                obj[key] = value;
                chrome.storage.local.set(obj).then(() => resolve());
            } catch (e) {
                window.localStorage.setItem(key, value);
                resolve();
            }
        });
    },
    remove: (key) => {
        return new Promise((resolve, reject) => {
            try {
                chrome.storage.local.remove(key).then(() => resolve());
            } catch (e) {
                window.localStorage.removeItem(key);
                resolve();
            }
        });
    },
}